import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class parser {
	public static void parse(File src,File out){
		try {
			BufferedReader input = new BufferedReader(new FileReader(src));
			PrintWriter outWriter = new PrintWriter(out);
			Scanner inScan = new Scanner("");
			String line = input.readLine();
			ArrayList<String> tokenLine = new ArrayList<String>();
			int lineLength;
			int index;
			int lineCount = 0;
			boolean checkKey;
			while(line != null){
				tokenizer.token(line,outWriter,inScan,tokenLine);
				lineCount++;
				lineLength = tokenLine.size();
				index = 0;
				String temp;
				//Will be 'if' statement
				while(lineLength > 0){
					temp = tokenLine.get(index);
					System.out.print(temp);
//					temp = temp.toUpperCase();
//					if(temp.equals("BEGIN")){
//						
//					} else if(temp.equals("WHILE")){
//						
//					} else if(temp.equals("DO")){
//						
//					} else if(temp.equals("IF")){
//						
//					} else if(temp.equals("ODD")){
//						
//					} else if(temp.equals("THEN")){
//						
//					} else if(temp.equals("END")){
//						
//					} else if(temp.equals("CALL")){
//						
//					} else if(temp.equals("IN")){
//						
//					} else if(temp.equals("OUT")){
//						
//					} else if(temp.equals("INTEGER")){
//						if(index < lineLength){
//							index++;
//							checkKey = isKeyword((temp = tokenLine.get(index)));
//							if(checkKey == true){
//								System.out.println("Invalid format at line number " + lineCount + ". Terminating execution.");
//								System.exit(0);
//							}
//						}
//					} else if(temp.equals("FLOAT")){
//						
//					} else if(temp.equals("VAR")){
//						
//					} else if(temp.equals("PROCEDURE")){
//						
//					} else{
//						if(index == 0){
//							System.out.println("Keyword not recognized at line count " + lineCount + ". Terminating execution.");
//							System.exit(0);
//						}
//					}
					//This index will eventually be gone.
					index++;
					//Used to stop while loop.
					lineLength--;
				}
				System.out.println("");
				tokenLine = new ArrayList<String>();
				line = input.readLine();
			}
			
			inScan.close();
			outWriter.close();
			input.close();
		} catch (IOException e) {
			System.out.println(e);
		}
	}
	
	public static boolean isKeyword(String x){
		boolean ret = false;
		if(x.equals("WHILE")){
			ret = true;
		} else if(x.equals("BEGIN")){
			ret = true;
		} else if(x.equals("DO")){
			ret = true;
		} else if(x.equals("IF")){
			ret = true;
		} else if(x.equals("ODD")){
			ret = true;
		} else if(x.equals("THEN")){
			ret = true;
		} else if(x.equals("END")){
			ret = true;
		} else if(x.equals("CALL")){
			ret = true;
		} else if(x.equals("IN")){
			ret = true;
		} else if(x.equals("OUT")){
			ret = true;
		} else if(x.equals("INTEGER")){
			ret = true;
		} else if(x.equals("FLOAT")){
			ret = true;
		} else if(x.equals("VAR")){
			ret = true;
		} else if(x.equals("PROCEDURE")){
			ret = true;
		}
		return ret;
	}
}